home *** CD-ROM | disk | FTP | other *** search
-
-
-
- Snd2wav: Converter for Tandy DeskMate .snd Files
- -------------------------------------------------
-
- Version 1.1
-
- Written by:
- Jeffrey L. Hayes
- 130 Forest Ave., Lot 1
- Orono, Me. 04473
- (207) 866-7903
- Internet: tvdog@delphi.com
-
- This program is in the public domain.
-
-
- Contents:
-
- 1. Purpose
- 2. How to Use Snd2wav
- 3. Possible Problems
- 4. About .snd Files
- 5. Other Programs for the Tandy Sound Chip
-
-
- 1. Purpose
-
- This is a companion program to Kenneth Udut's Conv2snd program for
- converting .wav and other formats to .snd. I did the revisions for
- version 2.00 of that program.
-
- This program converts DeskMate .snd files to RIFF WAVE format, allowing
- them to be played without the DeskMate Sound.pdm program. This allows
- sounds edited with Sound.pdm to be shared with users on non-Tandy
- machines.
-
- Version 1.1 now supports the new-format .snd files used on the 2500-
- series.
-
-
- 2. How to Use Snd2wav
-
- The simplest way to use Snd2wav is just to type its name:
-
- snd2wav
-
- The program will prompt you for the input filename (i.e., the .snd
- file). The filename may include drive and/or path. If you do not
- specify an extension, it defaults to ".snd". You may specify a file
- without an extension by ending the filename with a period. The output
- filename will be the same as the input filename you specify, including
- drive and/or path, but with a ".wav" extension.
-
- You can also specify the input file on the command line:
-
- snd2wav a:\sounds\scream
-
- The above will convert a:\sounds\scream.snd to a:\sounds\scream.wav (and
- possibly more - see below). Or you can specify both the input and
- output filenames:
-
- snd2wav c:oldsnd.snd \newsnd.
-
- The above will convert file "oldsnd.snd" in the current directory of
- drive C: and place the result in the root directory of the current drive
- as "newsnd" (without an extension).
-
- If all goes well, you will see something like the following:
-
- C:>snd2wav spockd
-
- Snd2wav, v. 1.1: DeskMate .snd to RIFF WAVE conversion program.
-
- Converting: spockd.snd
- Creating: spockd.wav
-
- Conversion complete. Thank you for using Snd2wav.
-
- You may also see this if you convert an instrument file with more than
- one note defined:
-
- I:\CONV2SND>snd2wav piano new
-
- Snd2wav, v. 1.1: DeskMate .snd to RIFF WAVE conversion program.
-
- Converting: piano.snd
- Creating: new.wav
- Creating: new2.wav
- Creating: new3.wav
-
- Conversion complete. Thank you for using Snd2wav.
-
- If the .snd is an instrument file with more than one note defined,
- Snd2wav converts each note to a separate .wav file, as above. There can
- be up to 16 notes in an .snd file. Snd2wav will generate new names from
- the original output filename as necessary by appending a digit, as
- above. The "digits" for the 10th through the 16th notes are letters "A"
- through "G". If the output filename is already 8 characters long, the
- last character will be overwritten by the digit:
-
- I:\CONV2SND>snd2wav cello longname.
-
- Snd2wav, v. 1.1: DeskMate .snd to RIFF WAVE conversion program.
-
- Converting: cello.snd
- Creating: longname.
- Creating: longnam2.
- Creating: longnam3.
-
- Conversion complete. Thank you for using Snd2wav.
-
- That's it. The output file is a valid .wav file playable on any machine
- with a .wav player.
-
-
- 3. Possible Problems
-
- If something goes wrong during the conversion, Snd2wav will do its best
- to tell you what it thinks the problem was, and what you should do about
- it. Its word should not be taken as gospel, however; it's just making
- its best guess about the probable cause of something that may have many
- possible causes.
-
- One error message that you are certain to see if you run out and try to
- convert the .snd files that came with DeskMate is the following:
-
- I:\CONV2SND>snd2wav h:piano.snd i:piano
-
- Snd2wav, v. 1.1: DeskMate .snd to RIFF WAVE conversion program.
-
- The input file you specified: h:piano.snd
- ... is compressed. Snd2wav can't convert compressed .snd's. Load the file
- into Sound.pdm, turn compression off, and resave the file. Then try again.
-
- You can convert piano.snd if you follow those directions. Compressed
- .snd's, as the message says, can't be converted. I don't know the
- compression algorithms used by Tandy, so this program can't interpret
- compressed sound data.
-
- Here is something else you might see:
-
- I:\CONV2SND>snd2wav piano b:piano
-
- Snd2wav, v. 1.1: DeskMate .snd to RIFF WAVE conversion program.
-
- Converting: piano.snd
-
- Unable to create file b:piano.wav.
- Either the name is not a valid filename, or the disk is write-protected, or
- there is already a read-only file with that name. Check the filename and
- unprotect the disk, then try again.
-
- In this case, I have a write-protected disk in drive B:. I have to
- remove the write-protection before I can write files on B:.
-
- Here is another that might be pretty common:
-
- I:\CONV2SND>snd2wav nosound
-
- Snd2wav, v. 1.1: DeskMate .snd to RIFF WAVE conversion program.
-
- Converting: nosound.snd
-
- Note number 1 of the input .snd file contains no samples. The .snd file was
- saved after a note was created but before sound was recorded for the note, or
- the .snd file is a new sound file with no data recorded into it. This note is
- being skipped.
-
- Conversion complete. Thank you for using Snd2wav.
-
- I'm trying to convert a file with no sound in it. What I did was start
- Sound.pdm without loading a data file, then "Save as ...". Note the
- "Conversion complete" message: Snd2wav does not consider this an error.
- There just isn't any sound to convert, so there isn't any output .wav
- created. The "Note number 1" might throw you if you haven't dealt with
- instrument files. Instrument files can contain several different sound
- samples for different musical notes. When it's converting an instrument
- file, Snd2wav makes a different .wav file for each note. The easiest
- way for me to do that sort of thing was to treat sound files as if they
- were instrument files with one note. In the above example, nosound.snd
- is a sound file that has nothing recorded into it. If I had an
- instrument file with something recorded into some notes but not others,
- I would have seen the message above for the unrecorded notes, but the
- recorded notes would have been converted correctly:
-
- I:\CONV2SND>snd2wav cello
-
- Snd2wav, v. 1.1: DeskMate .snd to RIFF WAVE conversion program.
-
- Converting: cello.snd
- Creating: cello.wav
- Creating: cello2.wav
-
- Note number 3 of the input .snd file contains no samples. The .snd file was
- saved after a note was created but before sound was recorded for the note, or
- the .snd file is a new sound file with no data recorded into it. This note is
- being skipped.
-
- Conversion complete. Thank you for using Snd2wav.
-
- Finally, here is an error you are likely to see if you make misteaks
- when you type, like I do:
-
- I:\CONV2SND>snd2wav celo
-
- Snd2wav, v. 1.1: DeskMate .snd to RIFF WAVE conversion program.
-
- File celo.snd does not exist.
- Check the filename and try again.
-
- One known *BUG* in this program is that it won't convert read-only .snd
- files, insisting that they "do not exist." This is a bug in the Turbo
- Pascal runtime library, and I don't have any immediate plans to fix it.
- The bug applies only to files made read-only with the Attrib +r command,
- not to files on a write-protected floppy disk. Use Attrib -r to
- unprotect your .snd file before you convert it (Snd2wav does not modify
- the .snd file).
-
- There are several other, less common, error messages you can get. What
- you should never see is a message like this:
-
- Runtime error 200 at 0000:1A3E.
-
- This type of error message indicates that I made a mistake in writing
- the program. If you get a message like this, I need to know about it so
- I can fix the problem in the next version of Snd2wav. You can reach me
- by phone, by U.S. mail, or by email, whatever is convenient. Be sure to
- write down the message so you can tell me what it says. See the top of
- this file to find out how to reach me.
-
- If you get any kind of error message you don't understand, call or write
- me and we will try to figure it out.
-
- For use in batch files, Snd2wav will return errorlevel 1 if anything
- goes wrong during the conversion, or errorlevel 0 if all is OK.
-
-
- 4. About .snd Files
-
- The following is provided for the benefit of those who may wish to
- create other programs using the Tandy DeskMate .snd format. You do not
- need to know anything in this section to use this program.
-
- There are two types of DeskMate .snd files, sound files and instrument
- files. Both contain 8-bit unsigned PCM samples. "PCM" stands for
- "pulse code modulation" and just means that the sound wave is sampled at
- fixed intervals and its level recorded. It's just like you used to do
- in high school algebra when you were asked to graph a function by
- evaluating it at various points. With Tandy PCM, the samples are
- integers in the range 0-255.
-
- Sound files are the simpler of the two types of .snd files. These are
- garden-variety sample files with a fixed-length header giving the name
- of the sound, the recording frequency, and the length of the sound.
- Sound files may be recorded at 5500Hz, 11kHz or 22kHz.
-
- Instrument files contain samples as well as frequency and looping
- information used by Music.pdm to represent an instrument. Instrument
- files provide for attack, sustain, and decay with several samples having
- different implied frequencies and being used by Music.pdm to represent
- the instrument in different pitch ranges. Up to 16 different notes
- (with 16 different samples) can be contained in one instrument file.
- Instrument files are always recorded at 11kHz. Snd2wav discards the
- extra information when converting instrument files, only extracting the
- note samples themselves. There is no standard place in the .wav format
- to put the extra information (it could conceivably go in an INFO chunk,
- but Snd2wav doesn't do that).
-
- Both sound files and instrument files may be compressed in one of two
- ways, "music" compression or "speech" compression, or they may be
- uncompressed. I don't know the compression algorithms, but simple file
- comparison reveals that "music" and "speech" compression are almost
- identical.
-
- The old-format DeskMate .snd file header consists of 16 bytes of fixed
- header information followed by one or more 28-byte note records. The
- sample information, which may be compressed, follows the header. The
- new-format .snd file header, used on the 2500-series, consists of 114
- bytes of fixed header followed by one or more 46-byte note records; it
- contains essentially the same information as the old header. Conv2snd
- creates old-format .snd files; the 2500's can read the old format.
-
- Many of the numbers below are given in hexadecimal, or base-16 notation.
- Hexadecimal is a common way to express numbers when programming at the
- machine level. In base-16, letters A through F are used to represent
- "digits" 10 through 15. Also: "word" is a 16-bit unsigned integer, and
- "dword" is a 32-bit unsigned integer.
-
- "American Standard Pitch" refers to the sound frequencies assigned to
- the various musical notes by the American Standards Association. Sound
- frequencies are based on A above middle C being 440 cycles per second.
- This A is called A4. An octave below that is A3, an octave above, A5.
- The frequency doubles with each octave increase in pitch. Sound.pdm
- does not display standard notes to you, though. Standard octaves begin
- at C, so you would have A#2, B2, C3. Sound.pdm starts its octaves at A.
-
- The sampling rate has nothing to do with the pitch frequency, except
- that the rate must be at least twice as high as the highest frequency
- you want to record.
-
- DeskMate .snd File Format - Fixed Header
- ----------------------------------------
-
- offset size what
- ------ ---- ----
-
- 0 byte 1Ah (.snd ID byte). Note that 1Ah = <cntrl>-Z, so
- if a user attempts to type the .snd file to the screen,
- nothing will be displayed.
-
- 1 byte Compression code: 0 = no compression; 1 = music
- compression; 2 = speech compression.
-
- 2 byte Number of notes in the instrument file. 1 if sound
- file. There can be up to 16 notes in an instrument
- file. Note: when an instrument file is created, it
- automatically has one unset note placed in it.
-
- 3 byte Instrument number. 0 if sound file; 0FFh if instrument
- file with no number set. Valid instrument numbers in
- an instrument file are 1 to 32. Use this field to
- distinguish a sound file from an instrument file.
-
- 4 10 bytes Sound or instrument name. Name is a null-terminated
- string, so there are up to 9 characters of the name,
- plus the null byte.
-
- 0Eh word Sampling rate in samples per second. Note that
- although a sampling rate other than 5500, 11000 and
- 22000 can be entered here, Sound.pdm will not actually
- play at other rates.
-
- 10h variable Note records begin, 28 bytes each. Number of records
- given in byte 2 above.
-
-
- DeskMate .snd File Format - Note Record
- ---------------------------------------
-
- 0 byte Pitch of the note: 1 = A1 in American Standard Pitch;
- 2 = A#1; etc. A1 is lowest note allowed; highest note
- allowed is B6 (3Fh). Sound files have 0FFh here; so do
- instrument files with no note set.
- Note that Sound.pdm does not designate notes in the
- standard manner to the user. Although A1 and B6 in
- Sound.pdm are the same as A1 and B6 in standard pitch,
- Sound.pdm starts octaves at A rather than at C (as is
- standard). Thus, middle C, C4 in standard pitch, is C3
- in Sound.pdm.
-
- 1 byte Sound files, and instrument files with no pitch set,
- have 0 here. If the pitch is set, this byte is 0FFh.
-
- 2 2 bytes Range of the note, first byte is lower limit, second
- is higher limit. Byte encoding as for offset 0 (i.e.,
- 01h to 3Fh). Sound files have FF FF here; so do
- instrument files with no range set.
-
- 4 dword Offset in the file where samples for this note begin
- (zero-relative), after compression if that was done.
-
- 8 dword If compressed, the length of the compressed data in the
- file for this note. Uncompressed files have 0 here.
-
- 0Ch 4 bytes Unknown. Set to zero.
-
- 10h dword Number of samples in the note, after decompression if
- necessary. 0 can appear here.
-
- 14h dword Number of sample at start of sustain region for the
- note, relative to the first (zeroth) sample of the note.
- For sound files, or if sustain is not set, this field is
- 0.
-
- 18h dword Number of sample at end of sustain region for the note,
- relative to the first (zeroth) sample of the note. For
- sound files, or if sustain is not set, this field is 0.
-
-
- For new-format files, the header looks like this:
-
- New Tandy .snd File Format - Fixed Header
- -----------------------------------------
-
- offset size what
- ------ ---- ----
-
- 0 10 bytes Null-terminated sound name.
-
- 0Ah 34 bytes Unknown.
-
- 2Ch 2 bytes New .snd ID: 1Ah 80h.
-
- 2Eh word Number of notes in the file.
-
- 30h word Sound (instrument) number.
-
- 32h 16 bytes Unknown.
-
- 42h word Compression code (0 = no compression, 1 = music
- compression, 2 = speech compression).
-
- 44h 20 bytes Unknown.
-
- 58h word Sampling rate in samples per second.
-
- 5Ah 24 bytes Unknown.
-
- 72h variable Note records begin. Number given by word at 2Eh above.
-
-
- New Tandy .snd File Format - Note Record
- ----------------------------------------
-
- 0 dword Link to next note record (offset in file of next note
- record). 0 if last.
-
- 4 2 bytes Unknown.
-
- 6 byte Pitch of note (01h-3Fh), 01 = A1 in American Standard
- Pitch; 0FFh if not set.
-
- 7 byte Unknown (compare old .snd format; value is 00h or 0FFh,
- but seemingly unrelated to the pitch setting).
-
- 8 2 bytes Range of note. First byte is lower limit, second is
- higher limit. Values as for byte at offset 6 above;
- 0FFh 0FFh if not set.
-
- 0Ah dword Offset in file of start of sound data for this sample.
-
- 0Eh dword Length of sample sound data in bytes.
-
- 12h dword Uncompressed length of sound data (number of samples).
-
- 16h 24 bytes Unknown.
-
-
- 5. Other Programs for the Tandy Sound Chip
-
- There are programs other than Sound.pdm that can record sounds on a
- Tandy with the proprietary sound. Here are a few of them. All can
- record and play back sounds of arbitrary length, unlike Sound.pdm. None
- allows you to edit sounds as Sound.pdm does. The first two are share-
- ware; the last is free.
-
- David Stewart's Sampler package records and plays raw headerless samples
- at near 11kHz and features voice activation. The registered version
- purportedly provides keyboard activation (nice because the voice
- activation seems to have a will of its own) and allows the sampling rate
- to be varied.
-
- Sean Haynes' Tndsound program records and plays sound files in its own
- proprietary format. The unregistered version of this package does not
- appear to be crippled. There is a menu-driven interface. This program
- offers sound filtering and control over the playback volume. Overall, I
- would say that Tndsound is better than Sampler. One drawback to this
- program is that it doesn't know how to compute the sampling rate in Hz
- from the DAC divider value, so it's hard to select a standard sampling
- rate (you have to specify the rate as a meaningless number). The
- default rate is around 9kHz.
-
- My Tspak package contains a program, Recwav, to record RIFF WAVE files
- at an arbitrary sampling rate (the default is 11kHz). It runs from the
- DOS command line. The rate is set in Hz. There is also a program,
- Playwav, that can play 8- or 16-bit mono or stereo .wav's at up to 65535
- Hz. Tspak contains other programs useful to Tandy owners, including one
- to convert .snd files to Amiga .mod samples for use in a .mod editor,
- and another to enable the Tandy DAC to be used with some programs that
- otherwise would not support it. Tspak also comes with source code and
- programming information if you want to write your own programs for the
- Tandy sound chip.
-
- Sampler and Tndsound are on Delphi in the PC-Compatibles .sig, Crossfire
- Database. If you are not on Delphi, write me and I'll mail you a copy.
- Tspak is on Simtel. ftp to:
-
- oak.oakland.edu
-
- and get file:
-
- /pub/msdos/sound/tspak.zip
-
- It is also worth noting that there is a Windows 3.1 sound driver for the
- Tandy DAC, available on some BBS's and from Radio Shack. It will work
- on the 1000RSX and the 2500-series.
-
- Happy listening!
-
- Jeff (tvdog@delphi.com)